package com.wc.codeforces.思维.Basil_s_Garden;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/30 23:34
 * @description https://codeforces.com/contest/1987/problem/C
 */
public class Main {
    /**
     * 思路：
     * 当前位置能不能动，取决于后面那个是否比自己小
     * 那需要知道后面是什么时候比自己小呢
     * 那就需要判断后面什么时候开始动, 也就是代码中的wait属性
     * 那如果计算wait呢
     * 分情况
     * h[i] > h[i + 1] 时候, 如果说 h[i] - h[i + 1] > wait, 就说明h[i] > h[i + 1]恒成立, res = h[i]
     *                      否则, h[i] 可以先到达 h[i + 1]的位置, 然后等待h[i + 1]变为 h[i + 1] - 1的时候,就可以开始动了
     *                      那就是h[i]开始等待的时候, 此时wait = wait - (h[i] - h[i + 1]) + 1, 多加的1s使得满足条件
     * h[i] <= h[i + 1] 时候, 那就比较简单了, 需要h[i + 1] -> h[i] - 1的时候h[i] 才能动,
     *                       此时的wait = h[i + 1] - h[i] + 1 + wait
     */

    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] h = new int[N];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            solve();
        }
        out.flush();
    }

    static void solve() {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) h[i] = sc.nextInt();
        // res 表示后面变成0所需要的时间, wait 表示后面的植物等待了多长时间开始变动
        long res = h[n], wait = 0;
        for (int i = n - 1; i >= 1; i--) {
            if (h[i] > h[i + 1]) {
                if (h[i] - h[i + 1] > wait) wait = 0;
                else wait = wait - (h[i] - h[i + 1]) + 1;
            } else {
                wait = wait + h[i + 1] - h[i] + 1;
            }
            res = h[i] + wait;
        }
        out.println(res);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}